package com.lancoo.ccas52.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lancoo.ccas52.entity.Teacher;
import com.lancoo.ccas52.entity.TeachingClass;
import com.lancoo.ccas52.entity.TeachingClassStudent;
import com.lancoo.ccas52.entity.TeachingClassTeacher;
import com.lancoo.ccas52.pojo.common.PageInfo;
import com.lancoo.ccas52.pojo.vo.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import java.util.List;

/**
 * <p>
 * 教学班 服务类
 * </p>
 *
 * @author quin.song
 * @since 2023-01-11
 */
public interface TeachingClassService extends IService<TeachingClass> {

    /**
     * 根据任务批量删除教学班相关数据
     *
     * @param taskId
     */
    void deleteClassRelated(List<Integer> taskId);

    /**
     * 批量删除教学班相关数据
     * @param teachingClassIds
     */
    Integer deleteClass(List<Long> teachingClassIds);

    /**
     * 批量新增教学班
     *
     * @param list
     * @return
     */
    List<TeachingClass> addBatchTeachingClass(List<TeachingClassInput> list,Boolean isUpdate);
    List<TeachingClass> addBatchTeachingClassV2(String schoolId, String term,List<TeachingClassInput> list,Boolean isUpdate);

    /**
     * 更新教学班
     *
     * @param teachingClassInput
     * @return
     */
    TeachingClass updateTeachingClass(TeachingClassInput teachingClassInput);
    TeachingClass updateTeachingClassV2(String schoolId, String term,TeachingClassInput teachingClassInput);

    /**
     * 点确定时统一处理教学班
     * @param schoolId
     * @param term
     * @param list
     * @return
     */
    List<TeachingClass> ensureTeachingClass(String schoolId, String term,List<TeachingClassInput> list);

    /**
     * 批量修改教师
     *
     * @param teachingClassId
     * @param teacherIds
     * @return
     */
    List<TeachingClassTeacher> updateTeacher(Long teachingClassId, List<Long> teacherIds);

    /**
     * 批量修改学生
     *
     * @param teachingClassId
     * @param studentIds
     * @return
     */
    List<TeachingClassStudent> updateStudent(Long teachingClassId, List<Long> studentIds);


    /**
     * 批量修改教学班基础信息
     *
     * @param list
     * @return
     */
    Boolean updateBatchTeachingClass(List<TeachingClassInput> list);

    /**
     * 判断是否有重复的教学班名称
     * @param schoolId
     * @param term
     * @param teachingClassName
     * @return
     */
    Boolean isExistTeachingClassName(String schoolId, String term,Long teachingClassId, String teachingClassName);

    /**
     * 合并教学班-
     * @param teachingClassIds
     * @return
     */
    Boolean combinedClass(List<Long> teachingClassIds);


    /**
     * 根据课程id获取教学班列表
     *
     * @param courseId
     * @param studyNature
     * @param teachingClassType
     * @return
     */
    List<TeachingClass> getByCourseIdAndStudyNature(Integer flag,Long courseId, Integer studyNature, Integer teachingClassType);

    /**
     * 获取本学期该课程的教学班数量
     * @param schoolId
     * @param term
     * @param courseId
     * @return
     */
    Long getTeachingClassNumByCourseId(String schoolId, String term,Integer flag,Long courseId);

    /**
     * 根据任务条件获取教学班列表
     *
     * @param page
     * @param taskId
     * @param handleState
     * @param selectState
     * @param courseTypeId
     * @param studyNature
     * @param courseNature
     * @param collegeId
     * @param keyWord
     * @return
     */
    PageInfo<TeachingClassCourseDto> getTeachingClassDtoByConditions(IPage page, Integer taskId, Integer handleState, Integer selectState, String courseTypeId, Integer studyNature,Integer majorProp, Integer courseNature, String collegeId, String keyWord, Integer teachingClassType, Integer minClassNum);

    /**
     * 确定在线选课 获取在线选课教学班列表
     * @param page
     * @param taskId
     * @param handleState
     * @param selectState
     * @param courseTypeId
     * @param studyNature
     * @param courseNature
     * @param majorProp
     * @param collegeId
     * @param keyWord
     * @param minClassNum
     * @return
     */
    PageInfo<TeachingClassCourseDto> getSelectionTeachingClass(IPage page, Integer taskId, Integer handleState, Integer selectState, String courseTypeId, Integer studyNature, Integer courseNature, Integer majorProp, String collegeId, String keyWord, Integer minClassNum);

        /**
         * 根据任务条件获取简单教学班列表
         * @param taskId
         * @param page
         * @param collegeId
         * @param keyWord
         * @return
         */
    PageInfo<RuleTeachingClassVo> getSimpleTeachingClass(Integer taskId, IPage page,String courseTypeId, Integer courseNature,Integer majorProp, String collegeId, String keyWord, Integer state);

    /**
     * 获取简单教学班
     * @param page
     * @param taskId
     * @param courseTypeId
     * @param studyNature
     * @param courseNature
     * @param collegeId
     * @return
     */
    PageInfo<TeachingClassCourseDto> getTeachingClass(IPage page, Integer taskId,String courseTypeId, Integer studyNature, Integer courseNature,Integer majorProp, String collegeId, List<Long> teachingClassIds,String keyWord,Long roomId);

    /**
     * 根据行政班获取教学班列表
     * @param taskId
     * @param classIds
     * @return
     */
    List<TeachingClassToClassDto> getTeachingClassByClass(Integer taskId,List<String> classIds);

    PageInfo<TeachingClassSegmentDto> getSegmentTeachingClass(IPage page, Integer taskId, String courseTypeId, Integer studyNature,  String collegeId, List<Long> classIds, String keyWord);
    /**
     * 根据任务条件获取环节教学班列表
     *
     * @param page
     * @param taskId
     * @param segmentTypeId
     * @param studyNature
     * @param collegeId
     * @param keyWord
     * @return
     */
    PageInfo<TeachingClassSegmentDto> getTeachingClassSegment(IPage page, Integer taskId, String segmentTypeId, Integer studyNature, String collegeId, String keyWord);

    /**
     * 批量修改教学班状态
     *
     * @param teachingClassIds
     * @param isEnable
     */
    void updateTeachingClassEnable(List<Long> teachingClassIds, Integer isEnable);


    /**
     * 统计教学班相关数据
     *
     * @param taskId
     * @param teachingClassType
     * @return
     */
    PublishStatisticsPre preStatistics(Integer taskId, Integer teachingClassType,Integer minClassNum);

    /**
     * 退选统计
     *
     * @param taskId
     * @return
     */
    PublishDeselectStatistic getDeselectStatistic(Integer taskId);

    /**
     * 根据课程id获取已分配教师
     *
     * @param courseId
     * @param teachingClassType
     * @return
     */
    List<Teacher> getTeacherByCourseId(Long courseId, Integer teachingClassType);

    /**
     * 根据教学班id获取教师列表
     * @param teachingClassId
     * @return
     */
    List<Teacher> getTeacherByTeachingId(Long teachingClassId);

    /**
     * 根据行政班获取拆班的教学班
     * @param taskId
     * @param classId
     * @return
     */
    SubTeachingClass getSubTeachingClass(Integer taskId,String classId);

    /**
     * 根据分班标识获取教学班
     * @param uniqueShiftSign
     * @return
     */
    List<TeachingClass> getByUniqueShiftSign(String uniqueShiftSign);


    /**
     * 生成导入基础平台excel文件
     * @param taskId
     * @param importMode 增量->在线选课教学班 覆盖->全部教学班
     * @return
     */
    String allTeachingClassToExcel(Integer taskId,String importMode);

    /**
     * 教学任务生成excel
     * @param taskId
     * @param collegeId
     * @param collegeName
     * @param courseTypeId
     * @param courseType
     * @param courseNature
     * @param studyNature
     * @return
     */
    String teachTaskToExcel(Integer taskId,String collegeId,String collegeName,String courseTypeId,String courseType,Integer courseNature,Integer studyNature);

    /**
     * 环节教学任务生成excel
     * @param taskId
     * @param collegeId
     * @param collegeName
     * @param segmentTypeId
     * @param segmentType
     * @param studyNature
     * @return
     */
    String segmentToExcel(Integer taskId, String collegeId, String collegeName, String segmentTypeId, String segmentType, Integer studyNature);

    /**
     * 预选课程 选课结果
     * @param taskId
     * @param collegeId
     * @param collegeName
     * @param courseTypeId
     * @param courseType
     * @param courseNature
     * @param studyNature
     * @param majorProp
     * @return
     */
    String preSelectToExcel(Integer taskId, String collegeId, String collegeName, String courseTypeId, String courseType, Integer courseNature, Integer studyNature, Integer majorProp);

    /**
     * 在线选课导出
     * @param taskId
     * @param collegeId
     * @param collegeName
     * @param courseTypeId
     * @param courseType
     * @param courseNature
     * @param studyNature
     * @param majorProp
     * @return
     */
    String csSelectToExcel(Integer taskId, String collegeId, String collegeName, String courseTypeId, String courseType, Integer courseNature, Integer studyNature,Integer majorProp);


    /**
     * 发布教学任务数据校验
     * @param taskId
     * @return
     */
    List<TeachingClass> checkPublishTeachTask(Integer taskId);

    /**
     * 发布教学任务
     * @param taskId
     * @return
     */
    boolean publishTeachTask(Integer taskId);

    /**
     * 导入教学班
     * @param importTeachingClass
     * @param file
     * @return
     */
    Boolean excelToTeachingClass(ImportTeachingClass importTeachingClass, MultipartFile file);

    /**
     * 导出开课计划
     * @param taskId
     * @param out
     */
    void teachTaskToExcel(Integer taskId, ServletOutputStream out);

    /**
     * 导入教学计划
     * @param taskId
     * @param file
     */
    FileImportInfo excelToTeachingTask(Integer taskId, MultipartFile file);
    FileImportInfo excelToTeachingTaskAll(Integer taskId, MultipartFile file);

    /**
     * 导入分班教学班
     * @param taskId
     * @param file
     * @return
     */
    FileImportInfo excelToSubClass(Integer taskId, MultipartFile file);
}
